﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"  
    			xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    			xmlns:t="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"
    			>

<xsl:template match="/">
  <html>
  <head>
    	<style type="text/css">
        h2 {color: sienna}
        p {margin-left: 20px}
        .resultsHdrRow { font-face: arial; padding: 5px }
        .resultsRow { font-face: arial; padding: 5px }
        .passed {color:green}
        .failed {color:red}
      </style>
    </head>
  <body>
    <h2>CokeZero Test Results</h2>
    <h3>Summary</h3>
    	<ul>
    		<li>Tests found:    <xsl:value-of select="t:TestRun/t:ResultSummary/t:Counters/@total"/></li>
    		<li>Tests executed: <xsl:value-of select="t:TestRun/t:ResultSummary/t:Counters/@executed"/></li>
    		<li>Tests passed:   <xsl:value-of select="t:TestRun/t:ResultSummary/t:Counters/@passed"/></li>
    		<li class="failed">Tests failed:   <xsl:value-of select="t:TestRun/t:ResultSummary/t:Counters/@failed"/></li>
    	</ul>
    <table border="1" width="80%" >
        <tr  class="resultsHdrRow">
          <th align="left">Test Name</th>
          <th align="left">Result</th>
        </tr>
        <xsl:for-each select="/t:TestRun/t:Results/t:UnitTestResult" >
          
            <xsl:if test="@outcome='Passed'">
              <tr valign="top" class="resultsRow">
                <td width='30%'>
                  <xsl:value-of select="@testName"/>
                </td>
                <td width='70%' class='passed'>
                  Pass
                </td>
                </tr>
            </xsl:if>

            <xsl:if test="@outcome='Failed'">
              <tr valign="top" class="resultsRow">
                <td width='30%'>
                  <xsl:value-of select="@testName"/>
                </td>
                <td width='70%' class="failed">
                  <div>
                    Failed<br/>
                    Message: <xsl:value-of select="t:Output/t:ErrorInfo/t:Message"/>
                  </div>
                </td>
              </tr>
            </xsl:if>
        </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>